package com.tian.controller;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tian.po.User;
import com.tian.service.UserService;

@Controller
@RequestMapping("/my")
public class UserController {
	@Autowired
	private UserService userService;
//	@RequestMapping(value="/selectUser",method=RequestMethod.POST)
//	public User selectUser(@RequestBody Integer id){
//		User user = userService.getUser(id);
//		return user;
//	}
	@RequestMapping(value="/selectUser",method=RequestMethod.POST)
	public @ResponseBody User getUser(Integer id){
		User user = userService.getUser(id);
		return user;
	}
//	@RequestMapping(value="/insertUser",method=RequestMethod.POST)
//	public String insertUser(@RequestBody User user){
//		userService.insertUser(user);
//		return "cg";
//	}
	@RequestMapping(value="/insertUser",method=RequestMethod.POST)
	public @ResponseBody String insertUser(User user){
		userService.insertUser(user);
		return "成功";
	}
	@RequestMapping(value="/delUser",method=RequestMethod.POST)
	public @ResponseBody String delUser(int id){
		userService.delUser(id);
		return "成功";
	}
	@RequestMapping(value="/updateUser",method=RequestMethod.POST)
	public @ResponseBody String updateUser(User user){
		userService.updateUser(user);
		return "成功";
	}
	
	

}
